import { Body, Controller, Get, Post, Param, Delete, Query, UseGuards  } from '@nestjs/common';
import { NameGenerationService } from './nameGeneration.service';
import { query } from 'express';
import { RateLimiterGuard } from 'nestjs-rate-limiter';


@Controller()
export class NameGenerationController {
  constructor(private readonly nameGenerationService: NameGenerationService) {}

  @UseGuards(RateLimiterGuard)  // 控制器级别
  @Post('nameGeneration')
  async submitNameGeneration(@Body() opts:any) {
    try {
        console.log("formData 获取到的值", query)
         const data = await this.nameGenerationService.generateName(opts);
      if (data === undefined) {
        return {
          code: 100000,
          data: [],
          message: 'ok',
        };
      } else {
        return {
          code: 0,
          data: data,
          message: "恭喜你，名字生成成功！"
        };
      }
    } catch (error) {
      console.log(error);
    }
  }
}
